import React, { FC, Fragment } from "react"
import { View } from "@tarojs/components"
import clsx from "clsx"
import AuthModal from "@/components/AuthModal"
import { pxTransform, ShareAppMessageReturn, useShareAppMessage } from "@tarojs/taro"
import "./index.scss"

interface IProps {
  /** @deprecated */
  loading?: boolean
  className?: string
  /** @default 0 */
  pageGap?: number
  style?: React.CSSProperties
  shareConfig?: ShareAppMessageReturn
}
const GpContainer: FC<IProps> = ({ children, className, pageGap = 0, style, shareConfig = {} }) => {
  useShareAppMessage(() => {
    return shareConfig
  })
  return (
    <Fragment>
      <View
        className={clsx("gp-container", className)}
        style={{
          paddingBottom: pxTransform(pageGap),
          ...style
        }}
      >
        {React.Children.map(children, child => {
          return child
        })}
      </View>
      <AuthModal />
    </Fragment>
  )
}

export default GpContainer
